<?php 
//print_r($HttpResult);
if(1==2){$HttpResult = new HttpResult();}

	  $HttpContentResult = $HttpResult->getHttpContentResult();
//	  Debug::print_r($HttpContentResult);
	  //$lang = Config::DEFAULT_LOCALE;
		$head = new HtmlHeader($HttpContentResult->getHeader());
		$head->addCSS('reset');
		$head->addCSS('print','', 'print');
		$head->addCSS('ie',  'css/ie', 'print',true);
		
		$head->addCSS('forum',"css/admin");		
		
		//<!-- PROGRAMACAO JS | JQUERY  -->
		$head->addJS(array('jquery', 'masked'));
		
    //MENU DROPDOWN
    $head->addJS('Menu principal','js/menu/ddsmoothmenu');
    $head->addCSS('Menu CSS','js/menu/ddsmoothmenu');
    
    //TINYMCE
    $head->addJS('tinymce','js/tinymce/jquery.tinymce');
    
    //FILEUPLOAD
    $head->addJS('so','js/uploadify/swfobject');
    $head->addJS('uploadify','js/uploadify/jquery.uploadify.v2.1.4.min');
    $head->addCSS('Upload CSS','js/uploadify/uploadify');
		       
		//SLIDER SHOW
		$head->addJS('cycle', 'js/cycle/jquery.cycle.min');
	
		//<!-- JQUERY UI  -->
		$head->addJS('UI', 'js/UI/js/jquery-ui-1.8.6.custom.min');
		$head->addCSS('UI','js/UI/css/smoothness/jquery-ui-1.8.6.custom');
		
     //SELECTMENU
    $head->addJS('selectmenu','js/UI/development-bundle/ui/jquery.ui.selectmenu');
    $head->addCSS('selectmenu CSS','js/UI/css/jquery.ui.selectmenu');
    
		//<!-- VTIP  -->
		$head->addJS('vtip', 'js/vtip/vtip');
		$head->addCSS('vtip', 'js/vtip/vtip');
		
		//<!-- TABLE SORTER -->
		$head->addJS('tablesorter', 'js/tablesorter/tablesorter');
		$head->addCSS('tablesorter', 'js/tablesorter/tablesorter');
    
    //<!-- PROGRAMACAO JS | JQUERY  -->
    $head->addJS(array('admin','admin_select', 'admin/newsletter/list'));
		
		$header_html = $head->show(TRUE);
$header_html = str_replace(array("democrart", "democrArt", "Democrart", "DemocrArt"), array("expressaoartistica", "Expressão Artística", "Expressão Artística", "Expressão Artística"), $header_html);
echo $header_html;
?>
 
<body>

<div id="main">
      <?php include "view/democrart/parts/admin/header.php" ?>
      
	  <div id="main_content">
	  
	  <div id="msgBox"></div>
	  			
		 <div id="box_right">
			<h1>Listar Emails</h1>
			
		    <form name="form1" id='newsRegister' method="post" action="<?php echo Config::getRootPath("newsletter/register"); ?> ">
		        
		        <dl>
		        	<dt><label for='username_newsletter'>NEWSLETTER - Inserir:</label></dt>
		        	<dd>
		        		<input type="text" id="username_newsletter" onfocus="if(this.value=='Inserir E-Mail') this.value='';" onblur="if(this.value=='') this.value='Inserir E-Mail';" value="Inserir E-Mail" name="emailMailing" />
		        	</dd>
		        	<dd>
		        		<input type="submit" style="font-size: 90%;" id='btOkFooter' class="btn" value="+" name="ok" />
		        	</dd>
		        </dl>
		 	</form>
			<?php
			if(DataHandler::getValueByArrayIndex($_POST, "email_search") != NULL){
			?>
			<div id="avisoFiltro">Procurado por: <?php echo DataHandler::getValueByArrayIndex($_POST, "email_search");?> - 
			<a href="<?php echo Config::getRootPath("admin/newsletter");?>">
				 Remover procura <img src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="Remover filtro"></img>
			</a>
			</div>
			<br />
			<?php } ?>
			
			<div class="news-search">
				<h1>PESQUISAR POR E-MAIL</h1>
				<form id="frmSearch" name="frmSearch" method="post" action="<?php echo Config::getRootPath("admin/newsletter")?>" class="frmSearch">
					<strong>E-mail: </strong>
					<input type="text" name="email_search" id="email_search" size="25" /> 
					<input type="submit" value="Procurar"  class="button">
				</form>
			</div>
		
			<div class="news-search">
				<h1>FILTRAR</h1>
				<?php
				if(DataHandler::getValueByArrayIndex($_POST, "date") != NULL){
					$date_filter = NULL;
					if(DataHandler::getValueByArrayIndex($_POST, "date_filter")){
						//tem busca, vai tratar essa variavel
						$date_filter = DataHandler::getValueByArrayIndex($_POST, "date_filter");
						if($date_filter == '1'){
							$date_filter = "Depois de";
						}else if($date_filter == '1'){
							$date_filter = "Igual a";
						}else if($date_filter == '-1'){
							$date_filter = "Antes de";
						}else{
							$date_filter = NULL;
						}
					}
				?>
				
					<div id="avisoFiltro" class="rad">Procurado por: <?php echo $date_filter." ".DataHandler::getValueByArrayIndex($_POST, "date");?> - 
					<a href="<?php echo Config::getRootPath("admin/newsletter");?>">
						 remover procura <img src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="remover filtro"></img>
					</a>
					</div>
					<br />
					<?php } ?>
		
					<form id="frmFilter" name="frmFilter" method="post" action="<?php echo Config::getRootPath("admin/newsletter")?>" class="filter">
						<strong>Critério:</strong>
						<select name="date_filter" id="date_filter">
							<option  value="1">Depois de</option>
							<option  value="0">Igual a</option>
							<option  value="-1">Antes de</option>
						</select>
						<strong>Data: </strong>
						<input type="text" name="date" id="date" size="25" />
						<input type="submit" value="Filtrar"  class="button">
					</form>
			</div>
			
			
			<div style="clear:both">
				<a class="bt-excel rad" href="<?php echo Config::getRootPath("admin/newsletter/excel")?>" target="blank">Baixar Excel</a>
				<table class="news tablesorter" style="width:570px !important;">
					<thead>
						<tr>
							<th>Email</th>
							<th>Data de Registro</th>
							<th>Excluir</th>
						</tr>
					</thead>
					<tbody>
					<?php foreach($HttpContentResult->arrayNewsletter as $newsletter){?>
						<tr id="newsletter_<?php echo $newsletter->id ?>">
							<td><?php echo $newsletter->email ?></td>
							<td><?php echo date("d-m-Y",strtotime($newsletter->date)); ?></td>
							<td class="ico"><a class="del" name="newsletter" id="<?php echo $newsletter->id ?>" href="<?php echo Config::getRootPath("admin/newsletter/delete/id.".$newsletter->id) ?>">
							<img id="del1" src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="Excluir" title="" /></td>
						</tr>
					<?php }?>
					<?php foreach($HttpContentResult->arrayUser as $user){?>
						<tr id="user_<?php echo $user->id ?>">
							<td><?php echo $user->email ?></td>
							<td><?php echo date("d-m-Y",strtotime($user->registred)); ?></td>
							<td class="ico no-sort"><a class="del" name="user" id="<?php echo $user->id ?>" href="<?php echo Config::getRootPath("admin/newsletter/delete/id.".$user->id."/deactive.user") ?>">
							<img id="del<?php echo $user->id ?>" src="<?php echo Config::getAsset("assets/img/icons/delete.jpg");?>" alt="Excluir" title="" /></td>
						</tr>
					<?php }?>
					</tbody>
				</table>
			</div>
			
			<!-- COMECO PAGINACAO -->
			<div style="clear: both;"></div>
			<div id="model-pagination" style="text-align: center;padding: 20px 0px 20px 0px;">
			<?php 
//				include_once("library/facil3/utils/Pagination.class.php");
//				$Pagination = new Pagination($HttpContentResult->page, $HttpContentResult->limit_page, $HttpContentResult->count_total);
//				$htmlPaginacao = $Pagination->getHtml();
//				echo $htmlPaginacao;
			?>
			
			</div>
		
		</div>
					
			
			<!-- FIM DO QUADRO -->
	
	</div>
	
</div>

</body>
</html>
